﻿using System;
using NRank.Algorithms.Strategies;
using NRank.Common;

namespace NRank.Algorithms
{
	/// <summary>
	/// Provides shared methods for top-k algorithms.
	/// </summary>
	internal static class Defaults
	{
		/// <summary>
		/// Implicit aggregate function (simple sum).
		/// </summary>
		/// <param name="arg1"></param>
		/// <param name="arg2"></param>
		/// <returns></returns>
		public static double DefaultAggregateFunction(double arg1, double arg2)
		{
			return arg1 + arg2;
		}

		/// <summary>
		/// Creates pulling strategy from enum.
		/// </summary>
		/// <param name="thresholdCounter">Threshold counter</param>
		/// <param name="pullingStrategyTypes">Pulling strategy</param>
		/// <returns></returns>
		public static IPullingStrategy GetPullStrategy(ThresholdCounter thresholdCounter, PullingStrategyTypes pullingStrategyTypes)
		{
			switch (pullingStrategyTypes)
			{
				case PullingStrategyTypes.Alternating:
					return new AlternatingPullingStrategy();
				case PullingStrategyTypes.MinimizeThreshold:
					return new ThresholdMinimizePullingStrategy(thresholdCounter);
				default:
					throw new NotImplementedException("Unknown pulling strategy: " + pullingStrategyTypes);
			}
		}
	}
}